using System;
using System.Collections;
// 定义状态接口
public interface IState
{
    void Handle();
}

// 定义具体状态A
public class ConcreteStateA : IState
{
    public void Handle()
    {
        Console.WriteLine("Handling in ConcreteStateA");
    }
}

// 定义具体状态B
public class ConcreteStateB : IState
{
    public void Handle()
    {
        Console.WriteLine("Handling in ConcreteStateB");
    }
}

// 定义具体状态C
public class ConcreteStateC : IState
{
    public void Handle()
    {
        Console.WriteLine("Handling in ConcreteStateC");
    }
}

// 定义环境类
public class Context
{
    private IState _state;

    public Context(IState state)
    {
        _state = state;
    }

    public void Request()
    {
        _state.Handle();
    }

    public void ChangeState(IState state)
    {
        _state = state;
    }
}

// 客户端代码
public class Client
{
    public static void Main()
    {
        Context context = new Context(new ConcreteStateA());
        context.Request(); // 输出: Handling in ConcreteStateA

        context.ChangeState(new ConcreteStateB());
        context.Request(); // 输出: Handling in ConcreteStateB

        context.ChangeState(new ConcreteStateC());
        context.Request(); // 输出: Handling in ConcreteStateC
    }
}

//输出结果
//Handling in ConcreteStateA
//Handling in ConcreteStateB
//Handling in ConcreteStateC